home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tcsel003.zip / PRINTER.PAS < prev    next >
Pascal/Delphi Source File  |  1992-10-16  |  2KB  |  63 lines

  1. unit Myprint;
  2. {$D-,I-,S-}
  3. interface
  4.  
  5. uses dos;
  6.  
  7. var
  8.   Prt        : array[1..2] of text;
  9.   Lst        : text absolute Prt;
  10.  
  11. function PrinterStatus(p: byte): byte;
  12. function PrinterReady(var b : byte; p: byte): boolean;
  13.  
  14. implementation
  15.  
  16. procedure RawMode(var L);       { make sure that device is in raw mode }
  17.   var
  18.     regs : registers;
  19.   begin
  20.     with regs do begin
  21.       bx   := TextRec(L).Handle;         { place the file handle in bx }
  22.       ax   := $4400;           { setup for function $44 sub-function 0 }
  23.       MSDos(regs);                              { execute dos function }
  24.       dl   := dl or $20;                            { bit 5 = raw mode }
  25.       dh   := 0;                                      { set dh to zero }
  26.       ax   := $4401;           { setup for function $44 sub-function 1 }
  27.       MSDos(regs)                               { execute dos function }
  28.     end; { with }
  29.   end; { RawMode }
  30.  
  31. function PrinterStatus(p: byte): byte;
  32.    { Returns the printer status. LPT1=p=1, LPT2=p=2 }
  33.    var regs   : registers; { from the dos unit                         }
  34.    begin
  35.      with regs do begin
  36.        dx := p - 1;        { The printer number                        }
  37.        ax := $0200;        { The function code for service wanted      }
  38.        intr($17,regs);     { $17= ROM bios int to return printer status}
  39.        PrinterStatus := ah;{ Bit 0 set = timed out                     }
  40.      end;                  {     1     = unused                        }
  41.    end;                    {     2     = unused                        }
  42.                            {     3     = I/O error                     }
  43.                            {     4     = printer selected              }
  44.                            {     5     = out of paper                  }
  45.                            {     6     = acknowledge                   }
  46.                            {     7     = printer not busy              }
  47.  
  48. function PrinterReady(var b : byte; p: byte): boolean;
  49.   begin
  50.     b := PrinterStatus(p);
  51.     PrinterReady := (b = $90)         { This may vary between printers }
  52.   end;
  53.  
  54. begin
  55.   assign(Prt[1],'LPT1');
  56.   rewrite(Prt[1]);
  57.   RawMode(Prt[1]);
  58.   assign(Prt[2],'LPT2');
  59.   rewrite(Prt[2]);
  60.   RawMode(Prt[2]);
  61. end.
  62.  
  63.